package org.dtc.countdown.server;

import java.util.Calendar;
import java.util.TimeZone;

import org.dtc.countdown.client.CountDown;

import com.google.gwt.user.server.rpc.RemoteServiceServlet;

/**
 * The server side implementation of the RPC service.
 */
@SuppressWarnings("serial")
public class CountDownServiceImpl extends RemoteServiceServlet implements
		CountDown {

	private static final TimeZone GMT = TimeZone.getTimeZone("GMT");
	private static Calendar CAL;
	
	public Long countDownServer() {
		if(CAL == null) {
			CAL = Calendar.getInstance(GMT);
			CAL.set(Calendar.YEAR, 2010);
			CAL.set(Calendar.MONTH, Calendar.APRIL);
			CAL.set(Calendar.DAY_OF_MONTH, 23);
			CAL.set(Calendar.HOUR_OF_DAY, 8);
			CAL.set(Calendar.MINUTE, 30);
			CAL.set(Calendar.SECOND, 00);
		}
		Calendar now = Calendar.getInstance(GMT);
		return (CAL.getTimeInMillis() - now.getTimeInMillis()) / 100;
	}
}
